home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 002a / be310.zip / VARTABS.CHS < prev    next >
Text File  |  1993-06-01  |  3KB  |  120 lines

  1. /* VARTABS.CHS    C.R.S. Schanck       2/22/93
  2. /* CHESS FUNCTION(S): conf_vtabs, set_vtabs, do_vtabs
  3. /*              DATE: 3/1/93
  4. /*            AUTHOR: C. Schanck
  5. /*
  6. /*       DESCRIPTION:
  7. /*
  8. /* Taken from two other ideas for other editors and adapted for Bingo,
  9. /* plus a bunch of my own ideas...
  10. /*
  11. /* This is a module for inclusion into the .CFG/.SET file pair which
  12. /* will add the functionality for variable tabs.  This version works 
  13. /* off of a character representation of tabs.
  14. /* 'conf_vtabs'   turns the use of variable tabs on and off
  15. /* 'set_vtabs'    allows the user to edit the character rep of the tabs
  16. /* 'do_vtabs'     a replacement for the 'insert_tab' function
  17. /* which will either use the variable tabs or the insert_tab
  18. /* function, depending on whether the 'vtabmode' variable is set to
  19. /* zero or not.
  20.  
  21. /* global variables for turning variable tabs on/off
  22. int vtabmode;
  23. char tset[80];        /* array for tab stops                       
  24. /* include a statment like strcpy(tset,"*   *        *        *        *");
  25. /* for the intial tab setup
  26.            
  27. /* turn vtabs on and off
  28. conf_vtabs
  29. {
  30.    char buf[40];
  31.    int i;
  32.    strcpy(buf,"Set Variable Tabs? (Now: ");
  33.    if(vtabmode)
  34.       strcat(buf,"ON");
  35.    else
  36.       strcat(buf,"OFF");
  37.    i=box_pick(buf,3,2,"Yes, Turn ON","No, Turn OFF","Toggle Current Setting");
  38.    if(i==0)
  39.       vtabmode=1;
  40.    else if(i==1)
  41.       vtabmode=0;
  42.    else if(i==2)
  43.       vtabmode=1-vtabmode;
  44.    return(1);
  45. }
  46.  
  47. /* this lets you change the tab stop setting
  48. set_vtabs
  49. {
  50.    char dest[80];
  51.    strcpy(dest,tset);
  52.    if(get_str(dest,"  Tabs?....0........0........0........0........0........0........0",70)!=27)
  53.    {
  54.       strcpy(tset,dest);
  55.    }
  56. }
  57.  
  58. /* this will allow you to use variable stop tabs.  The character
  59. /* buffer 'tset' holds the columns where tabstops are set.  A non
  60. /* space character indicates it is a tabstop.  The first column is
  61. /* always a tab stop.  The routine will force spaces to be inserted 
  62. /* if necessary to padd to the position.
  63. /*
  64. /* this should work regardless of the setting of the bounce cursor
  65. /* mode
  66.  
  67. do_vtabs
  68. {
  69.    int i,j,curx,ok;
  70.    char buf[20];
  71.  
  72.    if(vtabmode==0)      /* if no vtabs, do a normal tab and duck out
  73.       return(Insert_tab());
  74.  
  75.    ok=0;                         /* set flag saying we haven't found next tab
  76.    curx=ask("file_column");      /* current column
  77.  
  78.    if(curx<strlen(tset))
  79.    {                 
  80.       i=curx;
  81.       /* ok, there could be a next tabstop */
  82.       while(tset[i]==32)
  83.       {              
  84.          i=i+1;
  85.       }
  86.  
  87.       if(tset[i]!=0)
  88.          ok=1;
  89.  
  90.    }
  91.       
  92.    if(ok)                /* if we found one...
  93.    {                                      
  94.       i=i+1;
  95.       
  96.       j=0;               /* pad the string with spaces needed
  97.       while(j<(i-curx))
  98.       {
  99.          buf[j]=32;
  100.          j=j+1;
  101.       }
  102.       buf[j]=0;
  103.  
  104.       /* put the spaces in the file
  105.       put_text(1,ask("file_line"),curx,buf);
  106.       
  107.       /* now move to the proper column
  108.       sformat(buf,",%ld",i);          
  109.       b_cmd("jump",str(buf),key("return"));
  110.    }
  111.    else                          /* if not found
  112.    {
  113.       put_text(1,1,ask("file_line")+1,"");   /* pad 
  114.       Begin_line();                   /* go to beginning of next line.
  115.       Cursor_down();
  116.    }
  117.  
  118.    /* this routine always wins, so return 1
  119.    return(1);  
  120. }